<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic
  PUBLIC "-//OASIS//DTD DITA Composite//EN" "ditabase.dtd">
<topic id="topic1">
  <title id="dn20941">DISCARD</title>
  <body>
    <p id="sql_command_desc">Discards the session state.</p>
    <section id="section2">
      <title>Synopsis</title>
      <codeblock id="sql_command_synopsis">DISCARD { ALL | PLANS | TEMPORARY | TEMP }</codeblock>
    </section>
    <section id="section3">
      <title>Description</title>
      <p><codeph>DISCARD</codeph> releases internal resources associated with a database session.
        This command is useful for partially or fully resetting the session's state. There are
        several subcommands to release different types of resources. <codeph>DISCARD ALL</codeph> is
        not supported by Greenplum Database. </p>
    </section>
    <section id="section4">
      <title>Parameters</title>
      <parml>
        <plentry>
          <pt>PLANS</pt>
          <pd>Releases all cached query plans, forcing re-planning to occur the next time the
            associated prepared statement is used.</pd>
        </plentry>
        <plentry>
          <pt>SEQUENCES</pt>
          <pd>Discards all cached sequence-related state, including any preallocated sequence values
            that have not yet been returned by <codeph>nextval()</codeph>. (See <codeph>CREATE
              SEQUENCE</codeph> for a description of preallocated sequence values.) </pd>
        </plentry>
        <plentry>
          <pt>TEMPORARY/TEMP</pt>
          <pd>Drops all temporary tables created in the current session.</pd>
        </plentry>
        <plentry>
          <pt>ALL</pt>
          <pd>Releases all temporary resources associated with the current session and resets the
            session to its initial state.
            <note>Greenplum Database does not support <codeph>DISCARD ALL</codeph> and returns a
              notice message if you attempt to run the command.</note></pd>
          <pd>As an alternative, you can the run following commands to release temporary session
            resources:
            <codeblock>SET SESSION AUTHORIZATION DEFAULT;
RESET ALL;
DEALLOCATE ALL;
CLOSE ALL;
SELECT pg_advisory_unlock_all();
DISCARD PLANS;
DISCARD SEQUENCES;
DISCARD TEMP;</codeblock></pd>
        </plentry>
      </parml>
    </section>
    <section id="section6">
      <title>Compatibility</title>
      <p><codeph>DISCARD</codeph> is a Greenplum Database extension.</p>
    </section>
  </body>
</topic>
